import Vue from 'vue'
import Vuex from 'vuex'

Vue.use(Vuex)

const store = new Vuex.Store({
    state: {
        count: 0,
        globalData: {
            comment: 'shop',
            desc: '东软电商'
        },
        defaultAddress: {},
        user: {},
        cartNum: 0,
        curGoods: []
    },
    mutations: {
        increment(state) {
            state.count++
        },
        updateDefaultAddress(state, address) {
            state.defaultAddress = address
        },
        setUser(state, user) {
            state.user = user
        },
        setCartNum(state, payload) {
            state.cartNum = payload
        },
        // 直接支付时保存的商品
        setCurGoods(state, payload) {
            state.curGoods = payload
        }
    }
})
export default store